home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / msdos.arc / CHAPTER.001 next >
Text File  |  1989-03-01  |  24KB  |  425 lines

  1.  
  2.    **  Programmer's  Technical  Reference  for  MSDOS  and  the  IBM  PC **
  3.                         ┌─────────────────────────────┐
  4.                         │ Shareware Version, 12/16/88 │
  5.                         │  Please Register Your Copy  │
  6.                         └─────────────────────────────┘
  7.                        Copyright (c) 1988 Dave Williams
  8.  
  9.  
  10.                             C H A P T E R    O N E 
  11.  
  12.                            DOS TECHNICAL INFORMATION
  13.  
  14.  
  15. SOME HISTORY├──────────────────────────────────────────────────────────────────
  16.  
  17.  Development of MSDOS/PCDOS began in October 1980, when IBM began searching 
  18. the market for an operating system for the yet-to-be-introduced IBM PC.
  19. Microsoft had no real operating system to sell, but after some research licensed
  20. Seattle Computer Products' 86-DOS operating system, which had been written by a
  21. man named Tim Paterson earlier in 1980 for use on that company's line of 8086,
  22. S100 bus micros. 86-DOS (also called QDOS, for Quick and Dirty Operating System)
  23. had been written as more or less a 16-bit version of CP/M, since Digital
  24. Research was showing no hurry in introducing CP/M-86.
  25.  This code was hurriedly polished up and presented to IBM for evaluation. IBM
  26. had originally intended to use Digital Research's CP/M operating system, which
  27. was the industry standard at the time. Folklore reports everything from obscure
  28. legal entanglements to outright snubbing of the IBM representatives by Digital,
  29. irregardless, IBM found itself left with Microsoft's offering of "Microsoft Disk
  30. Operating System 1.0". An agreement was reached between the two, and IBM agreed
  31. to accept 86-DOS as the main operating system for thir new PC. Microsoft 
  32. purchased all rights to 86-DOS in July 1981, and "IBM PC-DOS 1.0" was ready for
  33. the introduction of the IBM PC in October 1981. IBM subjected the operating
  34. system to an extensive quality-assurance program, found well over 300 bugs, and
  35. decided to rewrite the programs. This is why PC-DOS is copyrighted by both IBM
  36. and Microsoft. 
  37.  
  38.  It is sometimes amusing to reflect on the fact that the IBM PC was not
  39. originally intended to run MSDOS. The target operating system at the end of the
  40. development was for a (not yet in existence) 8086 version of CP/M. On the other
  41. hand, when DOS was originally written the IBM PC did not yet exist! Although
  42. PC-DOS was bundled with the computer, Digital Research's CP/M-86 would probably
  43. have been the main operating system for the PC except for two things - Digital
  44. Research wanted $495 for CP/M-86 (considering PC-DOS was essentially free) and
  45. many software developers found it easier to port existing CP/M software to DOS
  46. than to the new version of CP/M.
  47.  
  48.  After eight years the wheel has turned a full circle. Digital Research aided 
  49. IBM in writing DOS 4.0, which was subsequently licensed back to Microsoft, 
  50. which has dropped further development of the operating system to tilt at the 
  51. windmills of OS/2. 
  52.  
  53.  MSDOS and PC-DOS have been run on more than just the IBM-PC and clones. There 
  54. was an expansion board for the Apple ][ that allowed one to run (some) well - 
  55. behaved DOS programs. There are expansion boards for the Commodore Amiga 2000,
  56. the Apple MacIntosh II, and the IBM RT PC allowing them to run DOS, the Atari
  57. STs can run an emulator program called PC-Ditto and boot any version of MSDOS
  58. with full functionality. Microsoft's OS/2 operating system incorporates the
  59. so-called "DOS Compatibility Box" to run DOS software; QNX will run DOS as a
  60. task, and a few Unix systems offer "DOS Merge" or control programs that allow
  61. DOS to run as a task.
  62.  
  63.  
  64. WHAT IS DOS?├──────────────────────────────────────────────────────────────────
  65.  
  66.  DOS exists as a high-level interface between an application program and the 
  67. computer. DOS stands for "Disk Operating System", which reflects the fact that 
  68. its main original purpose was to provide an interface between the computer and 
  69. its disk drives. 
  70.  DOS now lets your programs do simple memory management, I/O from the system 
  71. console, and assorted system tasks (time and date, etc) as well as managing 
  72. disk operations. Versions 3.1 and up also incorporate basic networking 
  73. functions.
  74.  With the introduction of installable device drivers and TSR (terminate but 
  75. stay resident) programs in DOS 2.0, the basic DOS functions may be expanded to 
  76. cover virtually any scale of operations required.
  77.  
  78.  
  79. OTHER OPERATING SYSTEMS├───────────────────────────────────────────────────────
  80.  
  81.  Various other operating systems are availible for the IBM PC. These include:
  82.  
  83. Digital Research CP/M-86
  84. Digital Research Concurrent CP/M-86 (multitasking)
  85. Digital Research Concurrent DOS (PC-DOS compatible, multitasking)
  86. Digital Research Concurrent DOS XM (PC-DOS compatible, multitasking, multiuser)
  87. Digital Research Concurrent DOS 386 (same, for 80386 computers)
  88. Digital Research DR-DOS 3.31 and 4.0  (PC-DOS clones)
  89. Wendin-DOS  (PC-DOS compatible, multitasking, multiuser)
  90. QNX   (multitasking, multiuser)
  91. UNIX  (various systems from IBM itself, Microsoft-SCO, Bell, and various UNIX
  92.        clones, single and multi user)
  93. MINIX (multitasking UNIX clone)
  94. PC-MOS/386 (PC-DOS clone, multiuser, multitasking)
  95.  
  96.  "Shell" programs exist which use DOS only for disk management while they more 
  97. or less comprise a new operating system. These include:
  98.  
  99.      DesQview                        Windows                     OmniView
  100.      GEM                             TopView                     TaskView
  101.  
  102.  
  103.  NEC V-series CPUs can execute Intel 8080/8085 8-bit instructions as well as
  104. the 16-bit 8088-up instructions. They can run standard Digital Research 8-bit 
  105. CP/M and MP/M directly, as well as other operating systems developed for that 
  106. processor.
  107.  
  108.  
  109.  
  110. SPECIFIC VERSIONS OF MS/PC-DOS├────────────────────────────────────────────────
  111.  
  112.  DOS 1.x is essentially 86-DOS. DOS 2.x kept the multiple file layout (the two 
  113. hidden files and COMMAND.COM) but for all practical purposes is an entirely 
  114. different operating system with backwards compatibility with 1.x. I seriously 
  115. doubt there has been much code from 1.x retained in 2.x. DOS 3.x is merely an 
  116. enhancement of 2.x; there seems little justification for jumping a whole 
  117. version number. DOS 4.0, originating as it did from outside Microsoft, can 
  118. justify a version jump. Unfortunately, 4.x seems to have very little to reason
  119. justify its existence - virtually all of its core features can be found in one 
  120. version or another of DOS 3.x.
  121.  
  122.  DOS version nomenclature: major.minor.minor. The digit to the left of the 
  123. decimal point indicates a major DOS version change. 1.0 was the first version. 
  124. 2.0 added support for subdirectorites, 3.0 added support for networking, 4.0 
  125. added support for Lotus-Intel-Microsoft EMS.
  126.  The first minor version indicates customization for a major application. For 
  127. example, 2.1 for the PCjr, 3.3 for the PS/2s. The second minor version does not 
  128. seem to have any particular meaning.
  129.  
  130.  The main versions of DOS are:
  131.  
  132.  PC-DOS 1.0   October  1981  original release
  133.  PC-DOS 1.1   June     1982  bugfix, double sided drive support
  134.  MS-DOS 1.25  June     1982  for early compatibles
  135.  PC-DOS 2.0   March    1983  for PC/XT, many UNIX-like functions
  136.  PC-DOS 2.1   October  1983  for PCjr, bugfixes for 2.0
  137.  MS-DOS 2.11  October  1983  compatible equivalent to 2.1
  138.  PC-DOS 3.0   August   1984  1.2 meg drive for PC/AT
  139.  PC-DOS 3.1   November 1984  bugfix for 3.0, implemented network support
  140.  MS-DOS 2.25  October  1985  compatible; extended foreign language support
  141.  PC-DOS 3.2   July     1986  720k 3.5 inch drive support for Convertible
  142.  PC-DOS 3.3   April    1987  for PS/2 series, 1.44 meg, multiple DOS partitions
  143.  PC-DOS 4.0   August   1988  over-32 meg DOS partitions, EMS support
  144.  
  145.  IBM's PC-DOS is considered to be the "standard" version of DOS; Microsoft has 
  146. sold MS-DOS over the counter only since version 3.2 (previously, Microsoft 
  147. sold its versions only to OEMs). Most versions of DOS functionally duplicate 
  148. the external DOS commands such as DISKCOPY, etc. Microsoft has announced that
  149. they will sell MS-DOS 4.0 only to OEMs, so it looks like the "generic" MS-DOS 
  150. was short-lived.
  151.  
  152.  Some versions of MS-DOS varied from PC-DOS in the availible external commands.
  153. Some OEMs only licensed the basic operating system code (the xxxDOS and xxxBIO
  154. programs, and COMMAND.COM) from Microsoft, and either wrote the rest themselves
  155. or contracted them from outside software houses like Phoenix. Most of the 
  156. external programs for DOS 3.x and 4.x are written in "C" while the 1.x and 2.x
  157. utilities were written in assembly language. Other OEMs required customized
  158. versions of DOS for their specific hardware configurations, such as Sanyo 55x
  159. and early Tandy computers, which were unable to exchange their DOS with the IBM
  160. version.
  161.  
  162.  At least two versions of DOS have been modified to be run entirely out of ROM.
  163. The Sharp PC5000 had MSDOS 1.25 in ROM, and the Toshiba 1000 and some Tandy 
  164. models have MSDOS 2.11 in ROM.
  165.  
  166.  PC-DOS 3.0 was extremely buggy on release. It does not handle the DOS 
  167. environment correctly and there are numerous documented problems with the 
  168. batch file parser. The network support code is also nonfunctional in this DOS 
  169. version. It is recommended that users upgrade to at least version 3.1.
  170.  
  171.  DEC MSDOS versions 2.11 for the Rainbow had the ANSI.SYS device driver built 
  172. into the main code. The Rainbow also supported a unique quad density, single
  173. sided floppy drive.
  174.  
  175.  IBM had a version 1.85 of PC-DOS in April 1983, after the introduction of DOS 
  176. 2.0. It was evidently for internal use only, supported multiple drive file 
  177. searches (a primitive form of PATH), builtin MODE sommands for screen support, 
  178. a /P parameter for TYPE for paused screens, an editable command stack like the
  179. public domain DOSEDIT.COM utility, and could be set up to remain completely 
  180. resident in RAM instead of a resident/transient part like normal DOS. It is a 
  181. pity some of the neat enhancements didn't make it into DOS 2.0. IBM also had 
  182. an internal use only version 3.4, evidently used while developing DOS 4.0.
  183.  
  184.  Some versions of DOS used in compatibles do not maintain the 1.x, 2.x, .....
  185. numbering system. Columbia Data Products computers labeled DOS 1.25 as DOS 
  186. 2.0. Early Compaqs labeled DOS 2.0 as DOS 1.x. Other versions incorporated 
  187. special features - Compaq DOS 3.31 and Wyse DOS 3.21 both support 32-bit File 
  188. Allocation Tables.
  189.  
  190.  AT&T DOS 3.1 differs from generic MSDOS 3.10 in its use of cluster-size and
  191. file allocation table structures. AT&T DOS appears to use rules not from 
  192. version 3, but rather those from version 2.
  193.  
  194.  Epson Equity III and ComputerLand 3.10 DOS's appear to use cluster techniques
  195. that are a cross between versions 2 and 3. On type DOS partitions, these DOS's
  196. use 3.x rules if the partition is larger than 32,680 sectors in total size.
  197. This implies 16 bit FAT entries as well. On partitions below this size, they
  198. will use 2.x rules, including the 12 bit FAT entries.
  199.  
  200.  Zenith DOS 3.x and Wyse DOS 3.2 have a builtin internal device driver to 
  201. handle up to 4 32Mb DOS partitions on a single hard disk. Wyse DOS 3.31 will 
  202. handle single partitions up to 512Mb with a 32-bit FAT.
  203.  
  204.  According to PC Week Magazine, July 4, 1988, Arabic versions of MSDOS are 
  205. shipping with a hardware copy-protection system from Rainbow Technologies. 
  206. This is similar to the short-lived system used by AutoCAD 2.52 and a very few 
  207. other MSDOS programs, where an adapter block is plugged into the parallel port
  208. and software makes use of coded bytes within the block. This type of copy
  209. protection has been common on Commodore products for several years, where it is
  210. called a "dongle."
  211.  The AutoCAD dongle was defeated by a small program written within weeks of 
  212. version 2.52's debut. Version 2.62 was released 3 months later, without the 
  213. dongle. The DOS dongle will, however, prevent the system from booting at all 
  214. unless it is found. 
  215.  This makes the Arabic version of MSDOS the first copy-protected operating 
  216. system, a dubious distinction at best. The modifications to the operating 
  217. system to support the dongle are not known at this time.
  218.  
  219.  Versions of DOS sold in Great Britain are either newer than those sold in the 
  220. US or use a different numbering system. DOS 3.4, 4.0, 4.1, 4.2, and 4.3 had 
  221. been released there between the US releases of 3.3 and 4.0.
  222.  MSDOS 4.0 was introduced in mid-1987 in Europe (at SICOB in Paris and sometime
  223. earlier by Apricot Computer in the UK). It apparently offers multitasking
  224. PROVIDED applications are specially written for it.
  225.  David Fraser (UK MD of Microsoft) is on record saying that DOS 4 is unlikely
  226. to set the world alight and is of interest only to specific OEM's who want its
  227. features for networking/comms etc. Standard DOS applications will run under DOS
  228. 4.x as a foreground task according to uncertain information. It differs from
  229. earlier versions only in allowing background tasks to run. No info about how
  230. many tasks/memory requirements etc. at this time. It will run an MS-DOS 3.2 or
  231. earlier type task in a foreground partition, and a specially written task in
  232. the background.
  233.  
  234.  Microsoft changed their OEM licensing agreements between DOS versions 2.x and
  235. 3.x. OEM versions of DOS 3.x must maintain certain data areas and undocumented
  236. functions in order to provide compatibility with the networking features of the
  237. operating system. For this reason, resident programs will be much more reliable
  238. when operating under DOS 3.x.
  239.  
  240.  IBM's release of DOS 4.0 (and the immediate subsequent release of a bugfix)
  241. is a dubious step "forward." DOS 4.0 is the first version of DOS to come with 
  242. a warranty; the catch is that IBM warrants it only for a very slim list of 
  243. IBM-packaged software. 4.0 has some minor EMS support, support for large hard 
  244. disks, and not much else. With its voracious RAM requirements and lack of 
  245. compatibility with previous versions of DOS (many major software packages 
  246. crash under DOS 4.0), plus the increase in price to a cool $150, there has 
  247. been no great rush to go to the newest DOS.
  248.  
  249.  
  250.  
  251. THE OPERATING SYSTEM HIERARCHY├────────────────────────────────────────────────
  252.  
  253.  The Disk Operating System (DOS) and the ROM BIOS serve as an insulating layer 
  254. between the application program and the machine, and as a source of services 
  255. to the application program.
  256.  The system heirarchy may be thought of as a tree, with the lowest level being 
  257. the actual hardware. The 8088 or V20 processor sees the computer's address 
  258. space as a ladder two bytes wide and one million bytes long. Parts of this 
  259. ladder are in ROM, parts in RAM, and parts are not assigned. There are also 
  260. 256 "ports" that the processor can use to control devices. 
  261.  The hardware is normally addressed by the ROM BIOS, which will always know
  262. where everything is in its particular system. The chips may usually also be
  263. written to directly, by telling the processor to write to a specific address or
  264. port. This sometimes does not work as the chips may not always be at the same
  265. addresses or have the same functions from machine to machine.
  266.  
  267.  
  268.  
  269. DOS STRUCTURE├─────────────────────────────────────────────────────────────────
  270.  
  271. DOS consists of four components:
  272.  
  273.  * The boot record
  274.  * The ROM BIOS interface  (IBMBIO.COM or IO.SYS)
  275.  * The DOS program file    (IBMDOS.COM or MSDOS.SYS)
  276.  * The command processor   (COMMAND.COM or aftermarket replacement)
  277.  
  278.  
  279. * The Boot Record
  280.  
  281.  The boot record begins on track 0, sector 1, side 0 of every diskette formatted
  282. by the DOS FORMAT command. The boot record is placed on diskettes to produce an
  283. error message if you try to start up the system with a nonsystem diskette in 
  284. drive A. For hard disks, the boot record resides on the first sector of the DOS
  285. partition. All media supported by DOS use one sector for the boot record.
  286.  
  287.  
  288. * Read Only Memory (ROM) BIOS Interface and Extensions
  289.  
  290.  The file IBMBIO.COM or IO.SYS is the interface module to the ROM BIOS.
  291. This file provides a low-level interface to the ROM BIOS device routines and 
  292. may contain extensions or changes to the system board ROMs. Some compatibles do
  293. not have a ROM BIOS to extend, and load the entire BIOS from disk. (Sanyo 55x,
  294. Viasyn machines). Some versions of MSDOS, such as those supplied to Tandy, are 
  295. named IBMBIO.COM but are not IBM files.
  296.  
  297.  
  298. * The DOS Program
  299.  
  300.  The actual DOS program is the file IBMDOS.COM or MSDOS.SYS. It provides a high-
  301. level interface for user (application) programs. This program consists of file
  302. management routines, data blocking/deblocking for the disk routines, and a
  303. variety of built-in functions easily accessible by user programs.
  304.  When a user program calls these function routines, they accept high-level
  305. information by way of register and control block contents. When a user program 
  306. calls DOS to perform an operation, these functions translate the requirement
  307. into one or more calls to IBMBIO.COM, MSDOS.SYS or system hardware to complete
  308. the request.
  309.     
  310.  
  311. * The Command Interpreter
  312.   
  313.  The command interpreter, COMMAND.COM, is the part you interact with on the 
  314. command line. It consists of these parts:
  315.     
  316. Resident Portion:
  317.  
  318.  The resident portion resides in memory immediately following IBMDOS.COM and its
  319. data area. This portion contains routines to process interrupts 22h (Terminate 
  320. Address), 23h (Ctrl-Break Handler), and 24h (Critical Error Handler), as well as
  321. a routine to reload the transient portion if needed. For DOS 3.x, this portion 
  322. also contains a routine to load and execute external commands, such as files 
  323. with exensions of COM or EXE.
  324.  
  325.  When a program terminates, a checksum is used to determine if the application 
  326. program overlaid the transient portion of COMMAND.COM. If so, the resident 
  327. portion will reload the transient portion from the area designated by COMSPEC= 
  328. in the DOS environment. If COMMAND.COM cannot be found, the system will halt.
  329.  
  330. NOTE: DOS 3.3+ checks for the presence of a hard disk, and will default to 
  331.       COMSPEC=C:\. Previous versions default to COMSPEC=A:\. Under some DOS
  332.       versions, if COMMAND.COM is not immediately availible for reloading
  333.       (i.e., swapping to a floppy with COMMAND.COM on it) DOS may crash.
  334.  
  335.  All standard DOS error handling is done within the resident portion of 
  336. COMMAND.COM.  This includes displaying error messages and interpreting the 
  337. replies to the "Abort, Retry, Ignore, Fail?" message.  
  338.  
  339.   
  340.  
  341.  
  342.  
  343. DOS INITIALIZATION├────────────────────────────────────────────────────────────
  344.  
  345.  The system is initialized by a software reset (Ctrl-Alt-Del), a hardware reset
  346. (reset button), or by turning the computer on. The Intel 80x8x series processors
  347. always look for their first instruction at the end of their address space 
  348. (0FFFF0h) when powered up or reset. This address contains a jump to the first 
  349. instruction for the ROM BIOS.
  350.  Built-in ROM programs (Power-On Self-Test, or POST, in the IBM) check machine
  351. status and run inspection programs of various sorts. Some machines set up a
  352. reserved RAM area with bytes indicating installed equipment (AT and PCjr). 
  353.  The ROM routine looks for a disk drive at A: or an option ROM (usually a hard
  354. disk) at absolute address C:800h. If no floppy drive or option ROM is found, the
  355. BIOS calls int 19h (ROM BASIC if it is an IBM) or displays error message. 
  356.  If a bootable disk is found, the ROM BIOS loads the first sector of information
  357. from the disk and then jumps into the RAM location holding that code. This code
  358. normally is a routine to load the rest of the code off the disk, or to "boot"
  359. the system. 
  360.  The following actions occur after a system initialization:
  361.  
  362.  1.  The boot record is read into memory and given control.    
  363.  
  364.  2.  The boot record then checks the root directory to assure that the first 
  365.      two files are IBMBIO.COM and IBMDOS.COM. These two files must be the 
  366.      first two files, and they must be in that order (IBMBIO.COM first, with 
  367.      its sectors in contiguous order).
  368.      NOTE: IBMDOS.COM need not be contiguous in version 3.x+.
  369.  
  370.  3.  The boot record loads IBMBIO.COM into memory.
  371.  
  372.  4.  The initialization code in IBMBIO.COM loads IBMDOS.COM, determines 
  373.      equipment status, resets the disk system, initializes the attached 
  374.      devices, sets the system parameters and loads any installable device 
  375.      drivers according to the CONFIG.SYS file in the root directory (if 
  376.      present), sets the low-numbered interrupt vectors, relocates IBMDOS.COM 
  377.      downward, and calls the first byte of DOS.
  378.      NOTE: CONFIG.SYS may be a hidden file.
  379.  
  380.  
  381.  
  382.  5.  DOS initializes its internal working tables, initializes the interrupt
  383.      vectors for interrupts 20h through 27h, and builds a Program Segment 
  384.      Prefix for COMMAND.COM at the lowest available segment. For DOS versions
  385.      3.10 up, DOS also initializes the vectors for interrupts 0Fh through 3Fh.
  386.      An initialization routine is included in the resident portion and assumes
  387.      control during startup. This routine contains the AUTOEXEC.BAT file
  388.      handler and determines the segment address where user application programs
  389.      may be loaded. The initialization routine is then no longer needed and is
  390.      overlaid by the first program COMMAND.COM loads.
  391.      NOTE: AUTOEXEC.BAT may be a hidden file.
  392.  
  393.  6.  IBMBIO.COM uses the EXEC function call to load and start the top-level
  394.      command processor. The default command processor is COMMAND.COM in the
  395.      root directory of the boot drive. If COMMAND.COM is in a subdirectory 
  396.      or another command processor is to be used, it must be specified by a
  397.      SHELL= statement in the CONFIG.SYS file.
  398.      A transient portion is loaded at the high end of memory. This is the
  399.      command processor itself, containing all of the internal command
  400.      processors and the batch file processor. For DOS 2.x, this portion also
  401.      contains a routine to load and execute external commands, such as files
  402.      with extensions of COM or EXE.
  403.       This portion of COMMAND.COM also produces the DOS prompt (such as "A>"),
  404.      reads the command from the standard input device (usually the keyboard or
  405.      a batch file), and executes the command. For external commands, it builds
  406.      a command line and issues an EXEC function call to load and transfer
  407.      control to the program.
  408.      NOTE: COMMAND.COM may be a hidden file.
  409.      NOTE: For IBM DOS 2.x, the transient portion of the command processor
  410.            contains the EXEC routine that loads and executes external commands.
  411.            For MSDOS 2.x+ and IBM DOS 3.x+, the resident portion of the command
  412.            processor contains the EXEC routine. 
  413.      NOTE: IBMBIO only checks for a file *named* "COMMAND.COM". It will load
  414.            any file of that name if no SHELL= command is used.
  415.  
  416.  
  417.  IBM's original documentation spoke of installing alternate command 
  418. interpreters (programs other than COMMAND.COM) with the SHELL= statement in 
  419. CONFIG.SYS. Unfortunately, IBM chose not to document much of the interaction 
  420. between IBMDOS.COM and IBMBIO.COM. By the time much of the interaction was 
  421. widely understood, too many commercial software programs had been written to 
  422. use peculiarities of COMMAND.COM itself. There is only one commercial 
  423. replacement for COMMAND.COM (a program called Command Plus) and it is not 
  424. widely known or used.
  425.